<template lang="jade">
h-loader-full(url='loader',:setdata='false')
  h-data-lister(data='list')

  m-title(icon="add",name="求职者列表")
    label 开始时间
    input(type='datetime-local', v-model="start_time")
    label 结束时间
    input(type='datetime-local', v-model="end_time")
    button(@click='filter_time') 过滤
  .box
    //人员信息
    table.list
      ml-header(data='姓名,电话,性别,年龄,求职意向,工作所在地,是否反馈,发布时间,反馈时间,备注,操作')
      tr
        td 
          input(type = 'text', style="width:60px", v-model="search.username") 
        td 
          input(type = 'text', style="width:80px", v-model="search.mobile") 
        td 
          select(v-model="search.sex") 
            option(value='', selected) 请选择
            option(value='男') 男
            option(value='女') 女
        td 
          input(type = 'text', style="width:30px", v-model="search.age") 
        td 
          input(type = 'text', style="width:100px", v-model="search.intention") 
        td 
          input(type = 'text', style="width:100px", v-model="search.area") 
        td 
        td 
        td 
        td 
        td 
          button(@click='searchdo(search)') 搜索




      tr(v-for='(n,i) in list')
        //td {{n.id}}
        td {{n.username}}
        td {{n.mobile}}
        td {{n.object.sex}}
        td {{n.object.age}}
        td {{n.object.intention}}
        td {{n.object.area}}
        td: input(type='checkbox',v-model='n.islink')
        td {{new Date(n.time_create * 1000).format('yyyy-MM-dd hh:mm:ss') }}
        td(v-if="n.time_check") {{new Date(n.time_check * 1000).format('yyyy-MM-dd hh:mm:ss') }}
        td(v-else)
        td: input(type='text',v-model='n.remark')
        td
          a(href='javascript:void(0)',@click='check(n)') 更新
          
    .command
      .page
        button(v-show='page>1', @click="pagego('last')") 上一页
        button {{page}}
        button(@click="pagego('next')") 下一页
        a.button(href='javascript:void(0)',@click='download()') 导出
             &nbsp;&nbsp;&nbsp;&nbsp;统计共有{{count_num}}条记录
</template>
<style>
  #title .filter{ padding-top: 0; }
</style>
<script>
import { MessageBox } from 'mint-ui'
export default {
	data () {
		return {
			loader:{
        list:'get/jobseeker/info?page=1'
      },
      list:[],
      page:1,
      count_num:0,
      start_time:"",
      end_time:"",

      search:{
        username:"",
        mobile:"",
        sex:"",
        age:"",
        intention:"",
        area:""
      }

		}
	},
  mounted () {
    //this.getcount()
  },
  watch:{
    list:function(){
      this.getcount();
      for(var key in this.list){
        if(this.list[key].object != null){
          this.list[key].object = eval('(' + this.list[key].object + ')');
        }else{
          this.list[key].object = {'sex':'', 'age':'', 'intention':'', 'area':''};
        }
        console.log(this.list[key].object);
      }
    }
  },
	methods: {
		loadAfter(data){
      this.list=data.list
		},
    check(obj){
      console.log('obj==',obj)
      this.$ajax.put('update/jobseekerinfo',{'id':obj.id,'islink':obj.islink,'remark':obj.remark},(res)=>{
        this.$msg.success('更新成功')
        setTimeout('window.location.reload()',1500)
      },(res)=>{
        this.$msg.error('更新失败')
      })
    },
    download(){
      	window.location.href = 'http://xiongan.manager.hesq.com.cn/rest/get/excel/jobseeker/info'
        // window.location.href = 'http://127.0.0.1:5110/rest/get/excel/jobseeker/info'
    },
    // 分页
    pagego (type) {
      var start_time = this.start_time;
      var end_time = this.end_time;
      var search = this.search;
      this.page = type == 'last' ? this.page - 1 : this.page + 1
      this.$ajax.get('get/jobseeker/info?&page=' + this.page + 
        '&start_time='+start_time+
        "&end_time="+end_time+
        '&username='+search.username+
        '&mobile='+search.mobile+
        '&sex='+search.sex+
        '&age='+search.age+
        '&intention='+search.intention+
        '&area='+search.area
      , (res) => {
        this.list = res.data
      }, (res) => {
        this.error(res.message)
      })
    },
    getcount(){
      var start_time = this.start_time;
      var end_time = this.end_time;
      this.$ajax.get('get/jobseeker/count?type=jobseekerinfo&start_time='+start_time+'&end_time='+end_time, (res) => {
        var count_num = 0;
        this.count_num = res.data[0].countnum
      }, (res) => {
        this.error(res.message)
      })
    },
    filter_time(){
      var start_time = this.start_time;
      var end_time = this.end_time;
      this.$ajax.get('get/jobseeker/info?&page=1&start_time='+start_time+"&end_time="+end_time+
        '&username='+search.username+
        '&mobile='+search.mobile+
        '&sex='+search.sex+
        '&age='+search.age+
        '&intention='+search.intention+
        '&area='+search.area
      , (res) => {
        this.list = res.data
      }, (res) => {
        this.error(res.message)
      })
      this.getcount();
    },
    searchdo(search){
      var start_time = this.start_time;
      var end_time = this.end_time;
      this.$ajax.get('get/jobseeker/info?&page=' + this.page +
        '&start_time='+start_time+
        "&end_time="+end_time+
        '&username='+search.username+
        '&mobile='+search.mobile+
        '&sex='+search.sex+
        '&age='+search.age+
        '&intention='+search.intention+
        '&area='+search.area
      , (res) => {
        this.list = res.data
      }, (res) => {
        this.error(res.message)
      })
    }
	}
}
</script>
<style>
  .button{background: #ff5700; padding: 2%; color: #fff; text-decoration-line: none;}
</style>
